import { reqUserLogin } from '@/api/user'

export default {
  namespaced: true,
  state: () => {
    return {
      profile: {
        id: '',
        nickname: '',
        token: ''
      }
    }
  },
  mutations: {
    setProfile (state, profile) {
      state.profile = profile
    }
  },
  actions: {
    async login ({ commit }, data) {
      const { result } = await reqUserLogin(data)

      commit('setProfile', result)
    }
  },
  getters: {
    getProfile (state) {
      return state.profile
    }
  }
}
